package com.xoa.humanResource.service;

import com.xoa.dao.attend.*;
import com.xoa.dao.department.DepartmentMapper;
import com.xoa.dao.users.UserExtMapper;
import com.xoa.dao.users.UsersMapper;
import com.xoa.humanResource.model.Integral;
import com.xoa.model.attend.*;
import com.xoa.model.department.Department;
import com.xoa.model.users.UserExt;
import com.xoa.model.users.Users;
import com.xoa.service.attend.wrapper.AttendSetWrappers;
import com.xoa.util.*;
import com.xoa.util.common.StringUtils;
import com.xoa.util.common.log.FileUtils;
import com.xoa.util.common.session.SessionUtils;
import com.xoa.util.common.wrapper.BaseWrapper;
import com.xoa.util.page.PageParams;
import oracle.sql.DATE;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.event.FocusEvent;
import java.rmi.server.UID;
import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;


    /**
     * 考勤统计接口重写
     */
    @Service
    @SuppressWarnings("all")
    public class AttendStatisticsService {

        public final String numberZero = "0";
        public final String numberOne = "1";
        public final String numberTwo = "2";
        public final String numberThree = "3";
        public final String numberFour = "4";
        public final String numberFive = "5";
        public final String numberSix = "6";


        @Autowired
        private AttendMapper attendMapper;
        @Autowired
        private AttendSetMapper attendSetMapper;
        @Autowired
        private UserExtMapper userExtMapper;
        @Autowired
        private UsersMapper usersMapper;
        @Autowired
        private DepartmentMapper departmentMapper;

        @Autowired
        private AttendEvectionMapper attendEvectionMapper;//出差
        @Autowired
        private AttendLeaveMapper attendLeaveMapper;//请假
        @Autowired
        private AttendanceOvertimeMapper attendanceOvertimeMapper;//加班
        @Autowired
        private AttendOutMapper attendOutMapper;//外出

        /**
         * 签到
         * @param attend
         * @param req
         * @param attendDate
         * @param uid
         * @return
         * @throws ParseException
         */
        public BaseWrapper newAttend(Attend attend, HttpServletRequest req, String attendDate, String uid) throws ParseException {
            AttendSetWrappers wrappers = new AttendSetWrappers();
            Date date = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            String str = sdf.format(date);
            Date date1 = sdf.parse(str);
            attend.setAid(0);
            attend.setDate(DateFormat.DateToStr(attendDate));
            int a = DateFormat.getWYQTime(str);
            attend.setAtime(a);
            Map<String, Object> map = new HashMap<String, Object>();
            // Integer uid = SessionUtils.getSessionInfo(req.getSession(), Users.class, new Users()).getUid();
            map.put("uid", uid);
            map.put("date", attendDate);
            map.put("type", attend.getType());
            List<Attend> attendList = attendMapper.selectAttend(map);
            if(!"0".equals(attend.getType())){
                if (attendList != null&&attendList.size()>0) {
                    wrappers.setFlag(false);
                    wrappers.setStatus(true);
                    wrappers.setMsg("重复签到");
                    wrappers.setCode("130050");
                    return wrappers;
                }
            }
            if (StringUtils.checkNull(attend.getAddress())) {
                wrappers.setFlag(false);
                wrappers.setStatus(true);
                wrappers.setMsg("考勤签到地址不能为空");
                wrappers.setCode("130060");
                return wrappers;
            }

            int res = attendMapper.addAttend(attend);
            if (res == 1) {
                wrappers.setFlag(true);
                wrappers.setStatus(true);
                wrappers.setMsg("签到成功");
            } else {
                wrappers.setFlag(false);
                wrappers.setStatus(true);
                wrappers.setMsg("签到失败");
            }

            return wrappers;
        }

        /**
         * 查询全部考勤   考勤设置
         * @return
         */
        public  BaseWrapper selectAttendSet(){
            AttendSetWrappers  wrappers=new AttendSetWrappers();
            List<AttendSet> attendSetList=attendSetMapper.selectAttendSet();
            if(attendSetList.size()>0){
                wrappers.setData(attendSetList);
                wrappers.setFlag(true);
                wrappers.setStatus(true);
                wrappers.setMsg("ok");


            }else {
                wrappers.setFlag(false);
                wrappers.setStatus(true);
                wrappers.setMsg("err");

            }
            return wrappers;
        }

        /**
         * 查询考勤类型统计  早退迟到请假。
         * @param date
         * @param uid
         * @param start
         * @param end
         * @param req
         * @return
         * @throws ParseException
         */

        public BaseWrapper myAttend(String date, Integer uid, String start, String end, HttpServletRequest req) throws ParseException {
            Cookie redisSessionCookie = CookiesUtil.getCookieByName(req, "redisSessionId");
            String sqlType = "xoa"+SessionUtils.getSessionInfo(req.getSession(), "loginDateSouse", String.class, redisSessionCookie);
            AttendSetWrappers wrappers = new AttendSetWrappers();
            Attend attend = new Attend();
            Map<String, Object> map = new HashMap<String, Object>();
            if (uid != null) {
                //Cookie redisSessionId = CookiesUtil.getCookieByName(req, "redisSessionId");
                uid = SessionUtils.getSessionInfo(req.getSession(), Users.class, new Users(),redisSessionCookie).getUid();
            }
            Cookie redisSessionId = CookiesUtil.getCookieByName(req, "redisSessionId");
            Users users = SessionUtils.getSessionInfo(req.getSession(), Users.class, new Users(),redisSessionId);
            map.put("uid", uid);
            map.put("date", date);
            UserExt userExt = userExtMapper.queryUserExt(uid);
            if (userExt != null) {
                AttendSet attendSet = attendSetMapper.selectAttendSetSid(Integer.valueOf(userExt.getDutyType()));
                int xqhbt = 0;
                String[] str1 = attendSet.getAtime1Set().split("\\|");
                if (numberOne.equals(str1[0])) {
                    xqhbt++;
                }
                attendSet.setAtime1Setother(str1[0]);
                attendSet.setCommute1(str1[1]);
                String[] str2 = attendSet.getAtime2Set().split("\\|");
                if (numberOne.equals(str2[0])) {
                    xqhbt++;
                }
                attendSet.setAtime2Setother(str2[0]);
                attendSet.setCommute2(str2[1]);
                String[] str3 = attendSet.getAtime3Set().split("\\|");
                if (numberOne.equals(str3[0])) {
                    xqhbt++;
                }
                attendSet.setAtime3Setother(str3[0]);
                attendSet.setCommute3(str3[1]);
                String[] str4 = attendSet.getAtime4Set().split("\\|");
                if (numberOne.equals(str4[0])) {
                    xqhbt++;
                }
                attendSet.setAtime4Setother(str4[0]);
                attendSet.setCommute4(str4[1]);
                String[] str5 = attendSet.getAtime5Set().split("\\|");
                if (numberOne.equals(str5[0])) {
                    xqhbt++;
                }
                attendSet.setAtime5Setother(str5[0]);
                attendSet.setCommute5(str5[1]);
                String[] str6 = attendSet.getAtime6Set().split("\\|");
                if (numberOne.equals(str6[0])) {
                    xqhbt++;
                }
                attendSet.setAtime6Setother(str6[0]);
                attendSet.setCommute6(str6[1]);
                if (attendSet != null) {
                    List<BaseAttend> attendances = new ArrayList<BaseAttend>();//出勤
                    List<BaseAttend> normals = new ArrayList<BaseAttend>();//正常判断
                    List<BaseAttend> fields = new ArrayList<BaseAttend>();//外勤
                    List<BaseAttend> leaveEarlies = new ArrayList<BaseAttend>();//早退
                    List<BaseAttend> lackCards = new ArrayList<BaseAttend>();//缺卡
                    List<BaseAttend> lates = new ArrayList<BaseAttend>();//迟到
                    List<BaseAttend> absenteeisms = new ArrayList<BaseAttend>();//旷工
                    List<BaseAttend> unitExceptions = new ArrayList<BaseAttend>();//设备异常
                    List<BaseAttend> normalNews = new ArrayList<BaseAttend>();//正常
                    List<BaseAttend> absenteeismRecord = new ArrayList<BaseAttend>();//旷工记录
                    List<BaseAttend> leaveEarlyRecord = new ArrayList<BaseAttend>();//早退记录
                    List<BaseAttend> lackCardRecord = new ArrayList<BaseAttend>();//缺卡记录
                    List<BaseAttend> lateRecord = new ArrayList<BaseAttend>();//迟到记录
                    List<BaseAttend> attendOutList = new ArrayList<BaseAttend>();//外出
                    List<BaseAttend> attendanceOvertimeList = new ArrayList<BaseAttend>();//加班
                    List<BaseAttend> attendEvectionList = new ArrayList<BaseAttend>();//出差
                    List<BaseAttend> attendLeaveList = new ArrayList<BaseAttend>();//请假
                    List<Attend> attendListFirst = new ArrayList<Attend>();


                    List<Attend> workList = new ArrayList<Attend>();
               /* List<Attend> legwork = new ArrayList<Attend>();
                List<Attend> chuqin = new ArrayList<Attend>();
                List<Attend> zhengchang = new ArrayList<Attend>();
                List<Attend> zaotui = new ArrayList<Attend>();   死掉的代码 呜呜呜呜呜
                List<Attend> queka = new ArrayList<Attend>();
                List<Attend> chidao = new ArrayList<Attend>();
                List<Attend> kuanggong = new ArrayList<Attend>();
                List<Attend> shebeiyichang = new ArrayList<Attend>();*/
               /* List<Attend> jiaban = new ArrayList<Attend>();
                List<Attend> waichu = new ArrayList<Attend>();
                List<Attend> chucha = new ArrayList<Attend>();
                List<Attend> qingjia = new ArrayList<Attend>();*/
                    String[] wDate = attendSet.getWorkdate().split(",");
          /* for(int i=0;i<wDate.length;i++){
                      小问题保留 回来需求明确解决
             }*/
                    List<Date> datss = new ArrayList<Date>();
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
                    SimpleDateFormat matter2 = new SimpleDateFormat("yyyy-MM-dd");
                    Date dt = new Date();
                    String a11 = df.format(dt);//获取当前日期
                    String stratDate = "";
                    String endDate = "";
                    if (start.equals(a11)) {

                        stratDate = start + "-01";
                        endDate = matter2.format(dt);//获取当前日期时间

                    } else {
                        Date date1 = df.parse(start);
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(date1);
                        int first1 = calendar.getActualMinimum(calendar.DAY_OF_MONTH);    //获取本月最小天数
                        int last1 = calendar.getActualMaximum(calendar.DAY_OF_MONTH);    //获取本月最大天数
                        stratDate = start + "-01";
                        endDate = start + "-" + last1;
                    }
                    List<BaseAttend> unitExceptionList = myAttendUnitException(stratDate, endDate, uid, req);

                    Date start1 = matter2.parse(stratDate);
                    Date end1 = matter2.parse(endDate);
                    Calendar c = Calendar.getInstance();
                    List<Date> dates = DateCompute.getBetweenDates(start1, end1);
                    for (Date nowdate1 : dates) {
                        c.setTime(nowdate1);
                        int weekInt = c.get(Calendar.DAY_OF_WEEK);
                        weekInt = weekInt - 1;
                        if (weekInt == 0) {
                            weekInt = 7;
                        }

                        String week = String.valueOf(weekInt);
                        if (attendSet.getWorkdate().contains(week)) {
                            datss.add(nowdate1);
                        }
                    }

                    for (Date nowdate : datss) {
                        List<Attend> zhengchang1 = new ArrayList<Attend>();
                        Attendance attendance = new Attendance();//出勤
                        Absenteeism absenteeism = new Absenteeism();//旷工

                        LeaveEarly leaveEarly = new LeaveEarly();//早退

                        Normal normal = new Normal();//正常
                        Late late = new Late();//迟到

                        LackCard lackCard = new LackCard();//缺卡

                        Normal normalNew = new Normal();//正常判断

                   /* Attend attend1zhengchang = new Attend();  死去的代码
                    Attend attend111 = new Attend();
                    Attend attend11 = new Attend();
                    Attend attend22 = new Attend();
                    Attend attend33 = new Attend();
                    Attend attend44 = new Attend();
                    Attend attend55 = new Attend();
                    Attend attend66 = new Attend();
                    Attend waiqinattend = new Attend();
                    Attend chuchaAtt = new Attend();*/


                        List<AttendOut> attendOuts = attendOutMapper.queryAttendOut(users.getUserId(), DateFormat.getDatestr(nowdate));
                        if (attendOuts.size() > 0 && attendOuts != null) {
                            Iterator<AttendOut> attendOutIterator = attendOuts.iterator();
                            while (attendOutIterator.hasNext()) {
                                AttendOut attendOut = attendOutIterator.next();
                                BaseAttend attendOutNew = new BaseAttend();
                                attendOutNew.setStrat(attendOut.getOutTime1());
                                attendOutNew.setEnd(attendOut.getOutTime2());
                                attendOutNew.setStr("原因:" + attendOut.getOutType());
                                attendOutNew.setHour("1");
                                attendOutList.add(attendOutNew);
                            }
                        }

                        List<AttendLeave> attendLeaves = attendLeaveMapper.selectAttendLeaveModify(users.getUserId(), DateFormat.getDatestr(nowdate));
                        if (attendLeaves.size() > 0 && attendLeaves != null) {
                            Iterator<AttendLeave> attendLeavesIteratorr = attendLeaves.iterator();
                            while (attendLeavesIteratorr.hasNext()) {
                                AttendLeave attendLeave = attendLeavesIteratorr.next();
                                BaseAttend attendLeaveNew = new BaseAttend();
                                attendLeaveNew.setStrat(DateFormat.getStrDate(attendLeave.getLeaveDate1()));
                                attendLeaveNew.setEnd(DateFormat.getStrDate(attendLeave.getLeaveDate2()));
                                attendLeaveNew.setStr("原因:" + attendLeave.getLeaveType());
                                attendLeaveNew.setHour("1");
                                attendLeaveList.add(attendLeaveNew);
                            }
                        }

                        List<AttendEvection> attendEvections = attendEvectionMapper.selectAttendEvectionModify(users.getUserId(), DateFormat.getDatestr(nowdate));
                        if (attendEvections.size() > 0 && attendEvections != null) {
                            Iterator<AttendEvection> attendEvectionIterator = attendEvections.iterator();
                            while (attendEvectionIterator.hasNext()) {
                                AttendEvection attendEvection = attendEvectionIterator.next();
                                BaseAttend attendEvectionNew = new BaseAttend();
                                attendEvectionNew.setStrat(DateFormat.getStrDate(attendEvection.getEvectionDate1()));
                                attendEvectionNew.setEnd(DateFormat.getStrDate(attendEvection.getEvectionDate2()));
                                attendEvectionNew.setStr("原因:" + attendEvection.getReason());
                                attendEvectionNew.setHour("1");
                                attendEvectionList.add(attendEvectionNew);
                            }
                        }
                        List<AttendanceOvertime> attendanceOvertimes = attendanceOvertimeMapper.queryAttendanceOvertime(users.getUserId(), DateFormat.getDatestr(nowdate));

                        if (attendanceOvertimes.size() > 0 && attendanceOvertimes != null) {
                            Iterator<AttendanceOvertime> attendanceOvertimeIterator = attendanceOvertimes.iterator();
                            while (attendanceOvertimeIterator.hasNext()) {
                                AttendanceOvertime attendanceOvertime = attendanceOvertimeIterator.next();
                                BaseAttend attendanceOvertimeNew = new BaseAttend();
                                attendanceOvertimeNew.setStrat(DateFormat.getStrDate(attendanceOvertime.getStartTime()));
                                attendanceOvertimeNew.setEnd(DateFormat.getStrDate(attendanceOvertime.getEndTime()));
                                attendanceOvertimeNew.setStr("原因:" + attendanceOvertime.getReason());
                                attendanceOvertimeNew.setHour(attendanceOvertime.getOvertimeHours());
                                attendanceOvertimeList.add(attendanceOvertimeNew);
                            }
                        }


                        Map<String, Object> maps = new HashMap<String, Object>();
                        maps.put("uid", uid);
                        maps.put("date", DateFormat.getDatestr(nowdate));
                        List<Attend> attendList111 = attendMapper.selectAttendList(maps);
                        if (attendList111.size() > 0) {//出勤
                            attendance.setWeek(DateCompute.getWeekOfDate(nowdate));
                            attendance.setDate(DateFormat.getDatestrTime(nowdate));
                            attendances.add(attendance);

                        } else {//旷工
                            if(!DateFormat.getDatestr(nowdate).equals(DateFormat.getCurrentTime2())){
                                List<AttendEvection> attendEvection = attendEvectionMapper.selectAttendEvectionModify(users.getUserId(), DateFormat.getDatestr(nowdate));
                                List<AttendLeave> attendLeave = attendLeaveMapper.selectAttendLeaveModify(users.getUserId(), DateFormat.getDatestr(nowdate));
                                if (attendEvection.size() == 0 && attendEvection.size() == 0) {
                                    Absenteeism absenteeismRecords = new Absenteeism();
                                    absenteeism.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    absenteeism.setDate(DateFormat.getDatestrTime(nowdate));
                                    absenteeismRecords.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    absenteeismRecords.setDate(DateFormat.getDatestrTime(nowdate));
                                    absenteeisms.add(absenteeism);
                                    absenteeismRecord.add(absenteeismRecords);
                                }
                            }



                        }
                   /* Field field=new Field();//外勤
                   maps.put("type", numberZero);
                    List<Attend> attendList1 = attendMapper.selectAttendList(maps);
                    if (attendList1.size() > 0) {
                        field.setWeek(DateCompute.getWeekOfDate(nowdate));
                        field.setDate(DateFormat.getDatestrTime(nowdate));
                        fields.add(field);
                    }*/

                        if (numberOne.equals(attendSet.getIsOut())) {
                            List<Attend> attend0 = attendMapper.selectAttend0(DateFormat.getDatestr(nowdate), uid);
                            if (attend0 != null && attend0.size() > 0) {
                                Iterator<Attend> attendIterator = attend0.iterator();
                                while (attendIterator.hasNext()) {
                                    Field field = new Field();//外勤
                                    Attend attend1 = attendIterator.next();
                                    field.setDate(DateFormat.getDatestrTime(nowdate));
                                    field.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                    field.setStr(attend1.getAddress());
                                    field.setPhoneId(attend1.getPhoneId());
                                    field.setCause(attend1.getRemark());
                                    fields.add(field);
                                }
                            }

                        }


                        //  for (Attend att : attendList) {
                        if (numberOne.equals(attendSet.getAtime1Setother())) {
                            String status = "";
                            Late latefirst = new Late();//迟到
                            Normal normalfirst = new Normal();//正常
                            LeaveEarly leaveEarlyfirst = new LeaveEarly();//早退
                            LeaveEarly leaveEarlyfirstRecord = new LeaveEarly();//早退
                            Late latefirstRecord = new Late();//迟到
                            Attend attend1 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberOne);
                            if (attend1 != null) {
                                if (numberOne.equals(attend1.getType())) {
                                    if (numberOne.equals(attendSet.getCommute1())) {
                                        String a1 = DateFormat.getwyqStrTime(attend1.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime1()).getTime()) {
                                            status = "迟到";
                                            latefirst.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                            latefirst.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latefirst.setDate(DateFormat.getDatestrTime(nowdate));

                                            latefirst.setStr("迟到(" + DateFormat.parseMillisecone(attend1.getAtime() - DateFormat.getWYQTime(attendSet.getAtime1())) + ")");
                                            latefirst.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime1());
                                            latefirstRecord.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                            latefirstRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latefirstRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            latefirstRecord.setStr("迟到(" + DateFormat.parseMillisecone(attend1.getAtime() - DateFormat.getWYQTime(attendSet.getAtime1())) + ")");
                                            latefirstRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime1());
                                            lates.add(latefirst);
                                            lateRecord.add(latefirstRecord);
                                            //  chidao.add(attend11);

                                        } else {
                                            status = "正常";
                                            normalfirst.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                            normalfirst.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalfirst.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalfirst);
                                            //  zhengchang1.add(attend11);
                                        }
                                    } else {
                                        String a1 = DateFormat.getwyqStrTime(attend1.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime1()).getTime()) {
                                            status = "早退";
                                            leaveEarlyfirst.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                            leaveEarlyfirst.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlyfirst.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlyfirst.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime1()) - attend1.getAtime()) + ")");
                                            leaveEarlyfirst.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime1());
                                            leaveEarlyfirstRecord.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                            leaveEarlyfirstRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlyfirstRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlyfirstRecord.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime1()) - attend1.getAtime()) + ")");
                                            leaveEarlyfirstRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime1());
                                            leaveEarlies.add(leaveEarlyfirst);
                                            leaveEarlyRecord.add(leaveEarlyfirstRecord);
                                            // zaotui.add(attend11);

                                        } else {
                                            status = "正常";
                                            normalfirst.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                            normalfirst.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalfirst.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalfirst);
                                        }
                                    }

                                }


                            } else {
                                status = "未签到";
                                LackCard lackCardfirst = new LackCard();
                                LackCard lackCardfirstRecord = new LackCard();
                                lackCardfirst.setTime(attendSet.getAtime1());
                                lackCardfirst.setWeek(DateCompute.getWeekOfDate(nowdate));
                                lackCardfirst.setDate(DateFormat.getDatestrTime(nowdate));
                                lackCardfirstRecord.setTime(attendSet.getAtime1());
                                lackCardfirstRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                lackCardfirstRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                lackCards.add(lackCardfirst);
                                lackCardRecord.add(lackCardfirstRecord);
                                //queka.add(attend11);

                            }


                        }
                        if (numberOne.equals(attendSet.getAtime2Setother())) {
                            String status = "";
                            Late latetwo = new Late();//迟到
                            Normal normaltwo = new Normal();//正常
                            LeaveEarly leaveEarlytwo = new LeaveEarly();//早退
                            Late latetwoRecord = new Late();//迟到
                            LeaveEarly leaveEarlytwoRecord = new LeaveEarly();//早退
                            Attend attend2 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberTwo);
                            if (attend2 != null) {
                                if (numberTwo.equals(attend2.getType())) {
                                    if (numberOne.equals(attendSet.getCommute2())) {
                                        int a22 = DateFormat.getWYQTime(attendSet.getAtime2());
                                        if (attend2.getAtime() > DateFormat.getWYQTime(attendSet.getAtime2())) {
                                            status = "迟到";
                                            latetwo.setTime(DateFormat.getwyqStrTime(attend2.getAtime()));
                                            latetwo.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latetwo.setDate(DateFormat.getDatestrTime(nowdate));
                                            latetwo.setStr("迟到(" + DateFormat.parseMillisecone(attend2.getAtime() - DateFormat.getWYQTime(attendSet.getAtime2())) + ")");
                                            latetwo.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime2());
                                            latetwoRecord.setTime(DateFormat.getwyqStrTime(attend2.getAtime()));
                                            latetwoRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latetwoRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            latetwoRecord.setStr("迟到(" + DateFormat.parseMillisecone(attend2.getAtime() - DateFormat.getWYQTime(attendSet.getAtime2())) + ")");
                                            latetwoRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime2());
                                            lates.add(latetwo);
                                            lateRecord.add(latetwoRecord);
                                            //  chidao.add(attend22);
                                        } else {
                                            status = "正常";
                                            normaltwo.setTime(DateFormat.getwyqStrTime(attend2.getAtime()));
                                            normaltwo.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normaltwo.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normaltwo);
                                        }
                                    } else {
                                        String a1 = DateFormat.getwyqStrTime(attend2.getAtime());
                                        if (attend2.getAtime() < DateFormat.getWYQTime(attendSet.getAtime2())) {
                                            status = "早退";
                                            leaveEarlytwo.setTime(DateFormat.getwyqStrTime(attend2.getAtime()));
                                            leaveEarlytwo.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlytwo.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlytwo.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime2()) - attend2.getAtime()) + ")");
                                            leaveEarlytwo.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime2());
                                            leaveEarlytwoRecord.setTime(DateFormat.getwyqStrTime(attend2.getAtime()));
                                            leaveEarlytwoRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlytwoRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlytwoRecord.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime2()) - attend2.getAtime()) + ")");
                                            leaveEarlytwoRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime2());
                                            leaveEarlies.add(leaveEarlytwo);
                                            leaveEarlyRecord.add(leaveEarlytwoRecord);
                                            //     zaotui.add(attend22);
                                        } else {
                                            status = "正常";
                                            normaltwo.setTime(DateFormat.getwyqStrTime(attend2.getAtime()));
                                            normaltwo.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normaltwo.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normaltwo);
                                        }
                                    }

                                }


                            } else {
                                status = "未签到";
                                LackCard lackCardtwo = new LackCard();
                                LackCard lackCardtwoRecord = new LackCard();
                                lackCardtwo.setTime(attendSet.getAtime2());
                                lackCardtwo.setWeek(DateCompute.getWeekOfDate(nowdate));
                                lackCardtwo.setDate(DateFormat.getDatestrTime(nowdate));
                                lackCardtwoRecord.setTime(attendSet.getAtime2());
                                lackCardtwoRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                lackCardtwoRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                lackCards.add(lackCardtwo);
                                lackCardRecord.add(lackCardtwoRecord);
                                //  queka.add(attend22);
                            }


                        }
                        if (numberOne.equals(attendSet.getAtime3Setother())) {
                            String status = "";
                            Late latethree = new Late();//迟到
                            Normal normalthree = new Normal();//正常
                            LeaveEarly leaveEarlythree = new LeaveEarly();//早退
                            Late latethreeRecord = new Late();//迟到
                            LeaveEarly leaveEarlythreeRecord = new LeaveEarly();//早退
                            Attend attend3 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberThree);
                            if (attend3 != null) {

                                if (numberThree.equals(attend3.getType())) {

                                    if (numberOne.equals(attendSet.getCommute2())) {
                                        String a1 = DateFormat.getwyqStrTime(attend3.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime3()).getTime()) {
                                            status = "迟到";
                                            latethree.setTime(DateFormat.getwyqStrTime(attend3.getAtime()));
                                            latethree.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latethree.setDate(DateFormat.getDatestrTime(nowdate));
                                            latethree.setStr("迟到(" + DateFormat.parseMillisecone(attend3.getAtime() - DateFormat.getWYQTime(attendSet.getAtime3())) + ")");
                                            latethree.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime3());
                                            latethreeRecord.setTime(DateFormat.getwyqStrTime(attend3.getAtime()));
                                            latethreeRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latethreeRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            latethreeRecord.setStr("迟到(" + DateFormat.parseMillisecone(attend3.getAtime() - DateFormat.getWYQTime(attendSet.getAtime3())) + ")");
                                            latethreeRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime3());
                                            lates.add(latethree);
                                            lateRecord.add(latethreeRecord);
                                            // chidao.add(attend33);
                                        } else {
                                            status = "正常";
                                            normalthree.setTime(DateFormat.getwyqStrTime(attend3.getAtime()));
                                            normalthree.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalthree.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalthree);
                                        }
                                    } else {
                                        String a1 = DateFormat.getwyqStrTime(attend3.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime3()).getTime()) {
                                            status = "早退";
                                            leaveEarlythree.setTime(DateFormat.getwyqStrTime(attend3.getAtime()));
                                            leaveEarlythree.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlythree.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlythree.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime3()) - attend3.getAtime()) + ")");
                                            leaveEarlythree.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime3());
                                            leaveEarlythreeRecord.setTime(DateFormat.getwyqStrTime(attend3.getAtime()));
                                            leaveEarlythreeRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlythreeRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlythreeRecord.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime3()) - attend3.getAtime()) + ")");
                                            leaveEarlythreeRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime3());
                                            leaveEarlies.add(leaveEarlythree);
                                            leaveEarlyRecord.add(leaveEarlythreeRecord);
                                            //zaotui.add(attend33);
                                        } else {
                                            status = "正常";
                                            normalthree.setTime(DateFormat.getwyqStrTime(attend3.getAtime()));
                                            normalthree.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalthree.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalthree);
                                        }
                                    }

                                }


                            } else {
                                status = "未签到";
                                LackCard lackCardthree = new LackCard();
                                LackCard lackCardthreeRecord = new LackCard();
                                lackCardthree.setTime(attendSet.getAtime3());
                                lackCardthree.setWeek(DateCompute.getWeekOfDate(nowdate));
                                lackCardthree.setDate(DateFormat.getDatestrTime(nowdate));
                                lackCardthreeRecord.setTime(attendSet.getAtime3());
                                lackCardthreeRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                lackCardthreeRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                lackCards.add(lackCardthree);
                                lackCardRecord.add(lackCardthreeRecord);
                                //      queka.add(attend33);
                            }


                        }
                        if (numberOne.equals(attendSet.getAtime4Setother())) {
                            String status = "";
                            Late latefour = new Late();//迟到
                            Normal normalfour = new Normal();//正常
                            LeaveEarly leaveEarlyfour = new LeaveEarly();//早退
                            LeaveEarly leaveEarlyfourRecord = new LeaveEarly();//早退
                            Late latefourRecord = new Late();//迟到
                            Attend attend4 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFour);
                            if (attend4 != null) {

                                if (numberFour.equals(attend4.getType())) {

                                    if (numberOne.equals(attendSet.getCommute4())) {
                                        String a1 = DateFormat.getwyqStrTime(attend4.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime4()).getTime()) {
                                            status = "迟到";
                                            latefour.setTime(DateFormat.getwyqStrTime(attend4.getAtime()));
                                            latefour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latefour.setDate(DateFormat.getDatestrTime(nowdate));
                                            latefour.setStr("迟到(" + DateFormat.parseMillisecone(attend4.getAtime() - DateFormat.getWYQTime(attendSet.getAtime4())) + ")");
                                            latefour.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime4());
                                            latefourRecord.setTime(DateFormat.getwyqStrTime(attend4.getAtime()));
                                            latefourRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latefourRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            latefourRecord.setStr("迟到(" + DateFormat.parseMillisecone(attend4.getAtime() - DateFormat.getWYQTime(attendSet.getAtime4())) + ")");
                                            latefourRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime4());
                                            lates.add(latefour);
                                            lateRecord.add(latefourRecord);
                                            //  chidao.add(attend44);
                                        } else {
                                            status = "正常";
                                            normalfour.setTime(DateFormat.getwyqStrTime(attend4.getAtime()));
                                            normalfour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalfour.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalfour);
                                        }
                                    } else {
                                        String a1 = DateFormat.getwyqStrTime(attend4.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime4()).getTime()) {
                                            status = "早退";
                                            leaveEarlyfour.setTime(DateFormat.getwyqStrTime(attend4.getAtime()));
                                            leaveEarlyfour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlyfour.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlyfour.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime4()) - attend4.getAtime()) + ")");
                                            leaveEarlyfour.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime4());
                                            leaveEarlyfourRecord.setTime(DateFormat.getwyqStrTime(attend4.getAtime()));
                                            leaveEarlyfourRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlyfourRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlyfourRecord.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime4()) - attend4.getAtime()) + ")");
                                            leaveEarlyfourRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime4());
                                            leaveEarlies.add(leaveEarlyfour);
                                            leaveEarlyRecord.add(leaveEarlyfourRecord);

                                            //S   zaotui.add(attend44);

                                        } else {
                                            status = "正常";
                                            normalfour.setTime(DateFormat.getwyqStrTime(attend4.getAtime()));
                                            normalfour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalfour.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalfour);
                                        }
                                    }

                                } else {
                                    status = "未签到";
                                    LackCard lackCardfour = new LackCard();
                                    LackCard lackCardfourRecord = new LackCard();
                                    lackCardfour.setTime(attendSet.getAtime4());
                                    lackCardfour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    lackCardfour.setDate(DateFormat.getDatestrTime(nowdate));
                                    lackCardfourRecord.setTime(attendSet.getAtime4());
                                    lackCardfourRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    lackCardfourRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                    lackCards.add(lackCardfour);
                                    lackCardRecord.add(lackCardfourRecord);
                                    // queka.add(attend44);
                                }


                            }


                        }
                        if (numberOne.equals(attendSet.getAtime5Setother())) {
                            String status = "";
                            Late latefive = new Late();//迟到
                            Late latefiveRecord = new Late();//迟到
                            Normal normalfour = new Normal();//正常
                            LeaveEarly leaveEarlyfive = new LeaveEarly();//早退
                            LeaveEarly leaveEarlyfiveRecord = new LeaveEarly();//早退
                            Attend attend5 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFive);
                            if (attend5 != null) {

                                if (numberFive.equals(attend5.getType())) {

                                    if (numberOne.equals(attendSet.getCommute5())) {
                                        String a1 = DateFormat.getwyqStrTime(attend5.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime5()).getTime()) {
                                            status = "迟到";
                                            latefive.setTime(DateFormat.getwyqStrTime(attend5.getAtime()));
                                            latefive.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latefive.setDate(DateFormat.getDatestrTime(nowdate));
                                            latefive.setStr("迟到(" + DateFormat.parseMillisecone(attend5.getAtime() - DateFormat.getWYQTime(attendSet.getAtime5())) + ")");
                                            latefive.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime5());
                                            latefiveRecord.setTime(DateFormat.getwyqStrTime(attend5.getAtime()));
                                            latefiveRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latefiveRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            latefiveRecord.setStr("迟到(" + DateFormat.parseMillisecone(attend5.getAtime() - DateFormat.getWYQTime(attendSet.getAtime5())) + ")");
                                            latefiveRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime5());
                                            lates.add(latefive);
                                            lateRecord.add(latefiveRecord);
                                            //  chidao.add(attend55);
                                        } else {
                                            status = "正常";
                                            normalfour.setTime(DateFormat.getwyqStrTime(attend5.getAtime()));
                                            normalfour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalfour.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalfour);
                                        }
                                    } else {
                                        String a1 = DateFormat.getwyqStrTime(attend5.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime5()).getTime()) {
                                            status = "早退";
                                            leaveEarlyfive.setTime(DateFormat.getwyqStrTime(attend5.getAtime()));
                                            leaveEarlyfive.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlyfive.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlyfive.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime5()) - attend5.getAtime()) + ")");
                                            leaveEarlyfive.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime5());
                                            leaveEarlyfiveRecord.setTime(DateFormat.getwyqStrTime(attend5.getAtime()));
                                            leaveEarlyfiveRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlyfiveRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlyfiveRecord.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime5()) - attend5.getAtime()) + ")");
                                            leaveEarlyfiveRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime5());
                                            leaveEarlies.add(leaveEarlyfive);
                                            leaveEarlyRecord.add(leaveEarlyfiveRecord);
                                            // zaotui.add(attend55);
                                        } else {
                                            status = "正常";
                                            normalfour.setTime(DateFormat.getwyqStrTime(attend5.getAtime()));
                                            normalfour.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalfour.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalfour);
                                        }
                                    }


                                } else {
                                    status = "未签到";
                                    LackCard lackCardfive = new LackCard();
                                    LackCard lackCardfiveRecord = new LackCard();
                                    lackCardfive.setTime(attendSet.getAtime5());
                                    lackCardfive.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    lackCardfive.setDate(DateFormat.getDatestrTime(nowdate));
                                    lackCardfiveRecord.setTime(attendSet.getAtime5());
                                    lackCardfiveRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    lackCardfiveRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                    lackCards.add(lackCardfive);
                                    lackCardRecord.add(lackCardfiveRecord);
                                    //  queka.add(attend55);
                                }


                            }


                        }
                        if (numberOne.equals(attendSet.getAtime6Setother())) {
                            String status = "";
                            Late latesix = new Late();//迟到
                            Late latesixRecord = new Late();//迟到
                            Normal normalsix = new Normal();//正常
                            LeaveEarly leaveEarlysix = new LeaveEarly();//早退
                            LeaveEarly leaveEarlysixRecord = new LeaveEarly();//早退
                            Attend attend6 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberSix);
                            if (attend6 != null) {

                                if (numberSix.equals(attend6.getType())) {

                                    if (numberOne.equals(attendSet.getCommute6())) {
                                        String a1 = DateFormat.getwyqStrTime(attend6.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime6()).getTime()) {
                                            status = "迟到";
                                            latesix.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
                                            latesix.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latesix.setDate(DateFormat.getDatestrTime(nowdate));
                                            latesix.setStr("迟到(" + DateFormat.parseMillisecone(attend6.getAtime() - DateFormat.getWYQTime(attendSet.getAtime6())) + ")");
                                            latesix.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime6());
                                            latesixRecord.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
                                            latesixRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            latesixRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            latesixRecord.setStr("迟到(" + DateFormat.parseMillisecone(attend6.getAtime() - DateFormat.getWYQTime(attendSet.getAtime6())) + ")");
                                            latesixRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime6());
                                            lates.add(latesix);
                                            lateRecord.add(latesixRecord);
                                            // chidao.add(attend66);
                                        } else {
                                            status = "正常";
                                            normalsix.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
                                            normalsix.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalsix.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalsix);
                                        }
                                    } else {
                                        String a1 = DateFormat.getwyqStrTime(attend6.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime6()).getTime()) {
                                            status = "早退";
                                            leaveEarlysix.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
                                            leaveEarlysix.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlysix.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlysix.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime6()) - attend6.getAtime()) + ")");
                                            leaveEarlysix.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime6());
                                            leaveEarlysixRecord.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
                                            leaveEarlysixRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            leaveEarlysixRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                            leaveEarlysixRecord.setStr("早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime6()) - attend6.getAtime()) + ")");
                                            leaveEarlysixRecord.setAtime(DateFormat.getDatestr(nowdate) + "  " + attendSet.getAtime6());
                                            leaveEarlies.add(leaveEarlysix);
                                            leaveEarlyRecord.add(leaveEarlysixRecord);
                                            //    zaotui.add(attend66);
                                        } else {
                                            status = "正常";
                                            normalsix.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
                                            normalsix.setWeek(DateCompute.getWeekOfDate(nowdate));
                                            normalsix.setDate(DateFormat.getDatestrTime(nowdate));
                                            normals.add(normalsix);
                                        }
                                    }


                                } else {
                                    status = "未签到";
                                    LackCard lackCardsix = new LackCard();
                                    LackCard lackCardsixRecord = new LackCard();
                                    lackCardsix.setTime(attendSet.getAtime6());
                                    lackCardsix.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    lackCardsix.setDate(DateFormat.getDatestrTime(nowdate));
                                    lackCardsixRecord.setTime(attendSet.getAtime6());
                                    lackCardsixRecord.setWeek(DateCompute.getWeekOfDate(nowdate));
                                    lackCardsixRecord.setDate(DateFormat.getDatestrTime(nowdate));
                                    lackCards.add(lackCardsix);
                                    lackCardRecord.add(lackCardsixRecord);
                                    // queka.add(attend66);
                                }

                            }


                        }
                        if (normals.size() >= xqhbt) {
                            normalNew.setWeek(DateCompute.getWeekOfDate(nowdate));
                            normalNew.setDate(DateFormat.getDatestrTime(nowdate));
                            normalNews.add(normalNew);

                        }
                        normals.clear();

                    }

                    List<Attend> attendList = new ArrayList<Attend>();
                    Attend attendfirst = new Attend();
                    attendfirst.setSname("迟到记录");
                    attendfirst.setRemarksList(lateRecord);


                    Attend attendtwo = new Attend();
                    attendtwo.setSname("早退记录");
                    attendtwo.setRemarksList(leaveEarlyRecord);
                    Attend attendthree = new Attend();
                    attendthree.setSname("缺卡记录");
                    attendthree.setRemarksList(lackCardRecord);
                    Attend attendfour = new Attend();
                    attendfour.setSname("旷工记录");
                    attendfour.setRemarksList(absenteeismRecord);
                    attendList.add(attendfirst);
                    attendList.add(attendtwo);
                    attendList.add(attendthree);
                    attendList.add(attendfour);
                    Attend attend1 = new Attend();
                    attend1.setSname("出勤天数");
                    if (attendances.size() > 0) {
                        attend1.setNum(attendances.size() + "");
                        attend1.setState(numberOne);
                    } else {
                        attend1.setNum(numberZero);
                        attend1.setState(numberZero);
                    }
                    attend1.setType("天");
                    attend1.setRemarksList(attendances);

                    Attend attend2 = new Attend();
                    attend2.setSname("正常签到");
                    if (normalNews.size() > 0) {
                        attend2.setNum(normalNews.size() + "");
                        attend2.setState(numberOne);
                    } else {
                        attend2.setNum(numberZero);
                        attend2.setState(numberZero);
                    }
                    attend2.setType("天");
                    attend2.setRemarksList(normalNews);
                    Attend attend3 = new Attend();
                    attend3.setSname("外勤签到");
                    if (fields.size() > 0) {
                        attend3.setNum(fields.size() + "");
                        attend3.setState(numberOne);
                    } else {
                        attend3.setNum(numberZero);
                        attend3.setState(numberZero);
                    }
                    attend3.setType("次");
                    attend3.setRemarksList(fields);
                    Attend attend4 = new Attend();
                    attend4.setSname("早退");
                    if (leaveEarlies.size() > 0) {
                        attend4.setNum(leaveEarlies.size() + "");
                        attend4.setState(numberOne);
                    } else {
                        attend4.setNum(numberZero);
                        attend4.setState(numberZero);
                    }
                    attend4.setType("次");
                    attend4.setRemarksList(leaveEarlies);
                    Attend attend5 = new Attend();
                    attend5.setSname("缺卡");
                    if (lackCards.size() > 0) {
                        attend5.setNum(lackCards.size() + "");
                        attend5.setState(numberOne);
                    } else {
                        attend5.setNum(numberZero);
                        attend5.setState(numberZero);
                    }
                    attend5.setType("次");
                    attend5.setRemarksList(lackCards);
                    Attend attend6 = new Attend();
                    attend6.setSname("迟到");
                    if (lates.size() > 0) {
                        attend6.setNum(lates.size() + "");
                        attend6.setState(numberOne);
                    } else {
                        attend6.setNum(numberZero);
                        attend6.setState(numberZero);
                    }
                    attend6.setType("次");
                    attend6.setRemarksList(lates);
                    Attend attend7 = new Attend();
                    attend7.setSname("旷工");
                    if (absenteeisms.size() > 0) {
                        attend7.setNum(absenteeisms.size() + "");
                        attend7.setState(numberOne);
                    } else {
                        attend7.setNum(numberZero);
                        attend7.setState(numberZero);
                    }
                    attend7.setType("天");
                    attend7.setRemarksList(absenteeisms);
                    Attend attend8 = new Attend();
                    attend8.setSname("设备异常");
                    if (unitExceptionList.size() > 0) {
                        attend8.setNum(unitExceptionList.size() + "");
                        attend8.setState(numberOne);
                    } else {
                        attend8.setNum(numberZero);
                        attend8.setState(numberZero);
                    }
                    attend8.setType("次");
                    attend8.setRemarksList(unitExceptionList);
                    Attend leave = new Attend();
                    leave.setSname("请假");
                    if (attendLeaveList.size() > 0) {
                        leave.setNum(attendLeaveList.size() + "");
                        leave.setState(numberOne);
                    } else {
                        leave.setNum(numberZero);
                        leave.setState(numberZero);
                    }
                    leave.setType("次");
                    leave.setRemarksList(attendLeaveList);
                    Attend overtime = new Attend();
                    overtime.setSname("加班");
                    if (attendanceOvertimeList.size() > 0) {
                        overtime.setNum(attendanceOvertimeList.size() + "");
                        overtime.setState(numberOne);
                    } else {
                        overtime.setNum(numberZero);
                        overtime.setState(numberZero);
                    }
                    overtime.setType("次");
                    overtime.setRemarksList(attendanceOvertimeList);

                    Attend goOut = new Attend();
                    goOut.setSname("外出");
                    if (attendOutList.size() > 0) {
                        goOut.setNum(attendOutList.size() + "");
                        goOut.setState(numberOne);
                    } else {
                        goOut.setNum(numberZero);
                        goOut.setState(numberZero);
                    }
                    goOut.setType("次");
                    goOut.setRemarksList(attendOutList);
                    Attend evection = new Attend();
                    evection.setSname("出差");
                    if (attendEvectionList.size() > 0) {
                        evection.setNum(attendEvectionList.size() + "");
                        evection.setState(numberOne);
                    } else {
                        evection.setNum(numberZero);
                        evection.setState(numberZero);
                    }
                    evection.setType("次");
                    evection.setRemarksList(attendEvectionList);

                    workList.add(attend1);
                    workList.add(attend2);
                    workList.add(attend3);
                    workList.add(attend4);
                    workList.add(attend5);
                    workList.add(attend6);
                    workList.add(attend7);
                    workList.add(attend8);
                    workList.add(leave);
                    workList.add(overtime);
                    workList.add(goOut);
                    workList.add(evection);
                    attend.setAttendList(workList);
                    attend.setList(attendList);
                    attend.setType(attendSet.getTitle());
                    wrappers.setFlag(true);
                    wrappers.setStatus(true);
                    wrappers.setData(attend);
                    wrappers.setMsg("更新成功");

                } else {
                    wrappers.setFlag(false);
                    wrappers.setStatus(true);
                    wrappers.setMsg("更新失败");

                }
            } else {
                wrappers.setFlag(false);
                wrappers.setStatus(true);
                wrappers.setMsg("更新失败");

            }

            return wrappers;
        }

        /**
         * ？考勤手机类型判断
         * @param start
         * @param end
         * @param uid
         * @param request
         * @return
         */
        public List<BaseAttend> myAttendUnitException(String start, String end, Integer uid, HttpServletRequest request) {
            Cookie redisSessionId = CookiesUtil.getCookieByName(request, "redisSessionId");
            Users users = SessionUtils.getSessionInfo(request.getSession(),
                    Users.class, new Users(),redisSessionId);
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("strat", start);
            map.put("end", end);
            map.put("uid", uid);
            List<Attend> attendList = attendMapper.queryCountPhone(map);
            List<Integer> attendList1 = new ArrayList<Integer>();
            List<Attend> attendList3 = new ArrayList<Attend>();
            List<BaseAttend> unitExceptionList = new ArrayList<BaseAttend>();

            Attend attendNew = new Attend();
       /* attend66.setTime(DateFormat.getwyqStrTime(attend6.getAtime()));
        attend66.setWeek(DateCompute.getWeekOfDate(nowdate));
        attend66.setDateName(DateFormat.getDatestrTime(nowdate));*/
            for (Attend attend1 : attendList) {
                attendList1.add(attend1.getCount());
                Integer a1 = attend1.getCount();
            }
            // System.out.println("最大值: " + Collections.max(attendList1));
            if (attendList1 != null && attendList1.size() > 0) {


                Integer integer = Collections.max(attendList1);
                int i = integer.intValue();
                double b = i * 0.3;
                for (Attend attend1 : attendList) {
                    if (b < attend1.getCount()) {

                    } else {

                        String phone = attend1.getPhoneId();
                        Map<String, Object> maps = new HashMap<String, Object>();
                        maps.put("phone", phone);
                        maps.put("strat", start);
                        maps.put("end", end);
                        List<Attend> attendList2 = attendMapper.queryAttendPhone(maps);
                        for (Attend attend11 : attendList2) {
                            UnitException unitException = new UnitException();
                            unitException.setDate(DateFormat.getDatestrTime(attend11.getDate()));
                            unitException.setTime(DateFormat.getwyqStrTime(attend11.getAtime()));
                            unitException.setPhoneId(attend11.getPhoneId());
                            unitException.setAtime(DateFormat.getDatestrTime(attend11.getDate()) + "    " + DateFormat.getwyqStrTime(attend11.getAtime()));
                            Map<String, Object> map1 = new HashMap<String, Object>();
                  /*  map1.put("phone", phone);
                    List<Attend> attendList4 = attendMapper.queryAttendPhone(map1);
                    for (Attend attend12 : attendList4) {*/
                            String msg = "";
                            if (!users.getUid().equals(attend11.getUid())) {
                                String name = usersMapper.getUsernameById(attend11.getUid());
                                msg = "疑似" + name + "代签";
                            } else {
                                msg = "新设备" + phone;
                            }
                            unitException.setStr(msg);
                            unitExceptionList.add(unitException);

                        }
                    }
                }
            }

            return unitExceptionList;}




        /**
         * 创建人：季佳伟
         * 创建时间：2017-11-20  下午4:30:17
         *
         * 方法介绍：查询当天登录人的考勤状况    （源码没有改动）左春晖修改部分逻辑。
         * 参数说明：
         */
        public BaseWrapper PersonalTodayAttendance(String attendDate,HttpServletRequest req) throws ParseException {
            Cookie redisSessionId = CookiesUtil.getCookieByName(req, "redisSessionId");
            String sqlType = "xoa" +SessionUtils.getSessionInfo(req.getSession(), "loginDateSouse", String.class, redisSessionId);

            Integer uid = SessionUtils.getSessionInfo(req.getSession(), Users.class, new Users(),redisSessionId).getUid();
            AttendSetWrappers wrappers = new AttendSetWrappers();
           // List<Attend> workList = new ArrayList<Attend>();
            List<Attend> attend = new ArrayList<Attend>();
            UserExt userExt = userExtMapper.queryUserExt(uid);
            if (userExt != null) {
                for(int i = 1;i <= 6;i++ ){
                   // Attend attend = attendMapper.selectAttendAll(attendDate, uid.toString(), i+"");
                   attend= attendMapper.selectAttendCompilations(attendDate, uid.toString(), i+"");
                    if(attend != null){
                        for (Attend attend1 : attend){
                            String time = DateFormat.getwyqStrTime(attend1.getAtime());
                            attend1.setTime(time);
                        }
//                        String time = DateFormat.getwyqStrTime(attend.getAtime());
//                        attend.setTime(time);
//                        workList.add(attend);
                    }
                }
                wrappers.setFlag(true);
                wrappers.setStatus(true);
                wrappers.setData(attend);//查到的时间集合。
                wrappers.setMsg("查询成功");
            }
            return wrappers;

        }
        /**
         * 创建人：季佳伟
         * 创建时间：2017-11-21  下午4:30:17
         * 方法介绍：查询登录人一段时间内的考勤状况
         * 参数说明：
         */
        public AttendSetWrappers AttendanceStatistics(String beginDate, String endDate,HttpServletRequest req) {
            AttendSetWrappers wrappers = new AttendSetWrappers();

            Date dateTime = new Date();
            SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
            String time = format.format(dateTime);
            Date dateTime1 = new Date();
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
            String time1 = format1.format(dateTime1);
            Cookie redisSessionId = CookiesUtil.getCookieByName(req, "redisSessionId");
            Integer uid = SessionUtils.getSessionInfo(req.getSession(), Users.class, new Users(),redisSessionId).getUid();
            AttendStatistics attendStatistics=new AttendStatistics();
            List<Date> date = new ArrayList<Date>();
            UserExt userExt = userExtMapper.queryUserExt(uid);
            if (userExt != null) {
                List<BaseAttend> normal = new ArrayList<BaseAttend>();//上班正常
                List<BaseAttend> normalyichang = new ArrayList<BaseAttend>();//设备异常
                List<BaseAttend> closed = new ArrayList<BaseAttend>();//下班正常
                List<BaseAttend> notSign = new ArrayList<BaseAttend>();//未签到
                List<BaseAttend> notOut = new ArrayList<BaseAttend>();//未签退
                List<BaseAttend> leaveEarly = new ArrayList<BaseAttend>();//早退
                List<BaseAttend> late = new ArrayList<BaseAttend>();//迟到
                List<BaseAttend> fields = new ArrayList<BaseAttend>();//外勤


                AttendSet attendSet = attendSetMapper.selectAttendSetSid(Integer.valueOf(userExt.getDutyType()));
                int xqhbt = 0;
                String[] str1 = attendSet.getAtime1Set().split("\\|");
                if (numberOne.equals(str1[0])) {
                    xqhbt++;
                }
                attendSet.setAtime1Setother(str1[0]);
                attendSet.setCommute1(str1[1]);
                String[] str2 = attendSet.getAtime2Set().split("\\|");
                if (numberOne.equals(str2[0])) {
                    xqhbt++;
                }
                attendSet.setAtime2Setother(str2[0]);
                attendSet.setCommute2(str2[1]);
                String[] str3 = attendSet.getAtime3Set().split("\\|");
                if (numberOne.equals(str3[0])) {
                    xqhbt++;
                }
                attendSet.setAtime3Setother(str3[0]);
                attendSet.setCommute3(str3[1]);
                String[] str4 = attendSet.getAtime4Set().split("\\|");
                if (numberOne.equals(str4[0])) {
                    xqhbt++;
                }
                attendSet.setAtime4Setother(str4[0]);
                attendSet.setCommute4(str4[1]);
                String[] str5 = attendSet.getAtime5Set().split("\\|");
                if (numberOne.equals(str5[0])) {
                    xqhbt++;
                }
                attendSet.setAtime5Setother(str5[0]);
                attendSet.setCommute5(str5[1]);
                String[] str6 = attendSet.getAtime6Set().split("\\|");
                if (numberOne.equals(str6[0])) {
                    xqhbt++;
                }

                Calendar c = Calendar.getInstance();
                List<Date> dates = DateCompute.getBetweenDates(DateFormat.DateToStr(beginDate), DateFormat.DateToStr(endDate));
                for (Date nowdate1 : dates) {
                    c.setTime(nowdate1);
                    int weekInt = c.get(Calendar.DAY_OF_WEEK);
                    weekInt = weekInt - 1;
                    if (weekInt == 0) {
                        weekInt = 7;
                    }

                    String week = String.valueOf(weekInt);
                    if (attendSet.getWorkdate().contains(week)) {
                        date.add(nowdate1);
                    }
                 }
                normalyichang   = myAttendUnitException(beginDate, endDate, uid, req);//手动去添加开始时间和结束时间去查询输入的时间段内的考勤统计
                for (Date nowdate : date) {
                    if (numberOne.equals(attendSet.getIsOut())) {
                        List<Attend> attend0 = attendMapper.selectAttend0(DateFormat.getDatestr(nowdate), uid);
                        if (attend0 != null && attend0.size() > 0) {
                            Iterator<Attend> attendIterator = attend0.iterator();
                            while (attendIterator.hasNext()) {
                                Field field = new Field();//外勤
                                Attend attend1 = attendIterator.next();
                                field.setDate(DateFormat.getDatestrTime(nowdate));
                                field.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                field.setStr(attend1.getAddress());
                                field.setPhoneId(attend1.getPhoneId());
                                field.setCause(attend1.getRemark());
                                fields.add(field);
                            }
                        }

                    }
                    if (numberOne.equals(attendSet.getAtime1Setother())) {
                        String status = "";
                        if (DateFormat.getDateTimes(attendSet.getAtime1()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                            if (numberOne.equals(attendSet.getCommute1())) {
                                Attend attend1 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberOne);
                                if (attend1 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend1.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime1()).getTime()) {
                                        status = "迟到";
                                        BaseAttend latesix = new BaseAttend();

                                        latesix.setStr("签到时间为：" + attendSet.getAtime1() + "迟到(" + DateFormat.parseMillisecone(attend1.getAtime() - DateFormat.getWYQTime(attendSet.getAtime1())) + ")");


                                        late.add(latesix);
                                    } else {
                                        status = "正常";
                                        BaseAttend normalB = new BaseAttend();
                                        normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend1.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        normal.add(normalB);
                                    }
                                }else {
                                    status = "未签到";
                                    BaseAttend notSignsix = new BaseAttend();
                                    notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime1() + ")");
                                    notSign.add(notSignsix);
                                }

                            } else {
                                Attend attend1 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberOne);
                                if (attend1 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend1.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime1()).getTime()) {
                                        status = "早退";
                                        BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                        leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend1.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime1()) - attend1.getAtime()) + ")");

                                        leaveEarly.add(leaveEarlysix);
                                    } else {
                                        status = "正常";
                                        BaseAttend closedB = new BaseAttend();
                                        closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend1.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        closed.add(closedB);

                                    }

                                } else {
                                    status = "未签到";
                                    BaseAttend notOutsix = new BaseAttend();
                                    notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime1() + ")");
                                    notOut.add(notOutsix);
                                }


                            }
                        }
                    }
                    if (numberOne.equals(attendSet.getAtime2Setother())) {
                        String status = "";
                        if (DateFormat.getDateTimes(attendSet.getAtime2()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                            if (numberOne.equals(attendSet.getCommute2())) {
                                Attend attend2 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberTwo);
                                if (attend2 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend2.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime2()).getTime()) {
                                        status = "迟到";
                                        BaseAttend latesix = new BaseAttend();

                                        latesix.setStr("签到时间为：" + attendSet.getAtime2() + "迟到(" + DateFormat.parseMillisecone(attend2.getAtime() - DateFormat.getWYQTime(attendSet.getAtime2())) + ")");


                                        late.add(latesix);
                                    } else {
                                        status = "正常";
                                        BaseAttend normalB = new BaseAttend();
                                        normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend2.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        normal.add(normalB);
                                    }
                                } else {
                                    status = "未签到";
                                    BaseAttend notSignsix = new BaseAttend();
                                    notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime2() + ")");
                                    notSign.add(notSignsix);
                                }

                            } else {
                                Attend attend2 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberTwo);
                                if (attend2 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend2.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime2()).getTime()) {
                                        status = "早退";
                                        BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                        leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend2.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime2()) - attend2.getAtime()) + ")");

                                        leaveEarly.add(leaveEarlysix);
                                    } else {
                                        status = "正常";
                                        BaseAttend closedB = new BaseAttend();
                                        closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend2.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        closed.add(closedB);

                                    }

                                } else {
                                    status = "未签到";
                                    BaseAttend notOutsix = new BaseAttend();
                                    notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime2() + ")");
                                    notOut.add(notOutsix);
                                }


                            }
                        }
                    }
                    if (numberOne.equals(attendSet.getAtime3Setother())) {
                        String status = "";
                        if (DateFormat.getDateTimes(attendSet.getAtime3()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                            if (numberOne.equals(attendSet.getCommute3())) {
                                Attend attend3 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberThree);
                                if (attend3 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend3.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime3()).getTime()) {
                                        status = "迟到";
                                        BaseAttend latesix = new BaseAttend();

                                        latesix.setStr("签到时间为：" + attendSet.getAtime3() + "迟到(" + DateFormat.parseMillisecone(attend3.getAtime() - DateFormat.getWYQTime(attendSet.getAtime3())) + ")");


                                        late.add(latesix);
                                    } else {
                                        status = "正常";
                                        BaseAttend normalB = new BaseAttend();
                                        normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend3.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        normal.add(normalB);
                                    }
                                } else {
                                    status = "未签到";
                                    BaseAttend notSignsix = new BaseAttend();
                                    notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime3() + ")");
                                    notSign.add(notSignsix);
                                }

                            } else {
                                Attend attend3 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberThree);
                                if (attend3 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend3.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime3()).getTime()) {
                                        status = "早退";
                                        BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                        leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend3.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime3()) - attend3.getAtime()) + ")");

                                        leaveEarly.add(leaveEarlysix);
                                    } else {
                                        status = "正常";
                                        BaseAttend closedB = new BaseAttend();
                                        closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend3.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        closed.add(closedB);

                                    }

                                } else {
                                    status = "未签到";
                                    BaseAttend notOutsix = new BaseAttend();
                                    notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime3() + ")");
                                    notOut.add(notOutsix);
                                }


                            }
                        }
                    }
                    if (numberOne.equals(attendSet.getAtime4Setother())) {
                        String status = "";
                        if (DateFormat.getDateTimes(attendSet.getAtime4()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                            if (numberOne.equals(attendSet.getCommute4())) {
                                Attend attend4 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFour);
                                if (attend4 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend4.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime4()).getTime()) {
                                        status = "迟到";
                                        BaseAttend latesix = new BaseAttend();

                                        latesix.setStr("签到时间为：" + attendSet.getAtime4() + "迟到(" + DateFormat.parseMillisecone(attend4.getAtime() - DateFormat.getWYQTime(attendSet.getAtime4())) + ")");


                                        late.add(latesix);
                                    } else {
                                        status = "正常";
                                        BaseAttend normalB = new BaseAttend();
                                        normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend4.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        normal.add(normalB);
                                    }
                                } else {
                                    status = "未签到";
                                    BaseAttend notSignsix = new BaseAttend();
                                    notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime4() + ")");
                                    notSign.add(notSignsix);
                                }

                            } else {
                                Attend attend4 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFour);
                                if (attend4 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend4.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime4()).getTime()) {
                                        status = "早退";
                                        BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                        leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend4.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime4()) - attend4.getAtime()) + ")");

                                        leaveEarly.add(leaveEarlysix);
                                    } else {
                                        status = "正常";
                                        BaseAttend closedB = new BaseAttend();
                                        closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend4.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        closed.add(closedB);

                                    }

                                } else {
                                    status = "未签到";
                                    BaseAttend notOutsix = new BaseAttend();
                                    notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime4() + ")");
                                    notOut.add(notOutsix);
                                }


                            }
                        }
                    }
                    if (numberOne.equals(attendSet.getAtime5Setother())) {
                        String status = "";
                        if (DateFormat.getDateTimes(attendSet.getAtime5()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                            if (numberOne.equals(attendSet.getCommute5())) {
                                Attend attend5 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFive);
                                if (attend5 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend5.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime5()).getTime()) {
                                        status = "迟到";
                                        BaseAttend latesix = new BaseAttend();

                                        latesix.setStr("签到时间为：" + attendSet.getAtime5() + "迟到(" + DateFormat.parseMillisecone(attend5.getAtime() - DateFormat.getWYQTime(attendSet.getAtime5())) + ")");


                                        late.add(latesix);
                                    } else {
                                        status = "正常";
                                        BaseAttend normalB = new BaseAttend();
                                        normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend5.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        normal.add(normalB);
                                    }
                                } else {
                                    status = "未签到";
                                    BaseAttend notSignsix = new BaseAttend();
                                    notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime5() + ")");
                                    notSign.add(notSignsix);
                                }

                            } else {
                                Attend attend5 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFive);
                                if (attend5 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend5.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime5()).getTime()) {
                                        status = "早退";
                                        BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                        leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend5.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime5()) - attend5.getAtime()) + ")");

                                        leaveEarly.add(leaveEarlysix);
                                    } else {
                                        status = "正常";
                                        BaseAttend closedB = new BaseAttend();
                                        closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend5.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        closed.add(closedB);

                                    }

                                } else {
                                    status = "未签到";
                                    BaseAttend notOutsix = new BaseAttend();
                                    notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime5() + ")");
                                    notOut.add(notOutsix);
                                }


                            }
                        }
                    }
                    if (numberOne.equals(attendSet.getAtime6Setother())) {
                        String status = "";
                        if (DateFormat.getDateTimes(attendSet.getAtime6()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                            if (numberOne.equals(attendSet.getCommute6())) {
                                Attend attend6 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberSix);
                                if (attend6 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend6.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime6()).getTime()) {
                                        status = "迟到";
                                        BaseAttend latesix = new BaseAttend();

                                        latesix.setStr("签到时间为：" + attendSet.getAtime6() + "迟到(" + DateFormat.parseMillisecone(attend6.getAtime() - DateFormat.getWYQTime(attendSet.getAtime6())) + ")");


                                        late.add(latesix);
                                    } else {
                                        status = "正常";
                                        BaseAttend normalB = new BaseAttend();
                                        normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend6.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        normal.add(normalB);
                                    }
                                }else {
                                    status = "未签到";
                                    BaseAttend notSignsix = new BaseAttend();
                                    notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime6() + ")");
                                    notSign.add(notSignsix);
                                }

                            } else {
                                Attend attend6 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberSix);
                                if (attend6 != null) {

                                    String a1 = DateFormat.getwyqStrTime(attend6.getAtime());
                                    if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime6()).getTime()) {
                                        status = "早退";
                                        BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                        leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend6.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime6()) - attend6.getAtime()) + ")");

                                        leaveEarly.add(leaveEarlysix);
                                    } else {
                                        status = "正常";
                                        BaseAttend closedB = new BaseAttend();
                                        closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend6.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                        closed.add(closedB);

                                    }

                                } else {
                                    status = "weiqiandao";
                                    BaseAttend notOutsix = new BaseAttend();
                                    notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime6() + ")");
                                    notOut.add(notOutsix);
                                }


                            }
                        }
                    }
                }



                attendStatistics.setCount1(normal.size());
                attendStatistics.setCount1List(normal);//上班正常

                attendStatistics.setCount2(closed.size());
                attendStatistics.setCount2List(closed);//下班正常

                attendStatistics.setCount3(notSign.size());
                attendStatistics.setCount3List(notSign);//未签到

                attendStatistics.setCount4(notOut.size());
                attendStatistics.setCount4List(notOut);//未签退

                attendStatistics.setCount5(late.size());
                attendStatistics.setCount5List(late);//迟到

                attendStatistics.setCount6(leaveEarly.size());
                attendStatistics.setCount6List(leaveEarly);//早退

                attendStatistics.setCount7(normalyichang.size());
                attendStatistics.setCount7List(normalyichang);//異常

                attendStatistics.setCount8(fields.size());
                attendStatistics.setCount8List(fields);//外勤




            }

            if(attendStatistics != null){
                wrappers.setFlag(true);
                wrappers.setStatus(true);
                wrappers.setData(attendStatistics);
                wrappers.setMsg("查询成功");
            }else {
                wrappers.setFlag(false);
                wrappers.setStatus(true);
                wrappers.setMsg("查询失敗");
            }
            return wrappers;
        }

        //考勤统计查询
        public AttendSetWrappers TotalAttendanceStatistics(String beiginDate, String endDate, String deptId, String dutyType,
                                                        String uids, HttpServletRequest req) {
            AttendSetWrappers wrappers = new AttendSetWrappers();
            Map<String, Object> objectMap = new HashMap<String, Object>();
            //部门id
            objectMap.put("deptId", deptId);
            //考勤类型
            objectMap.put("dutyType", dutyType);
            //用户id
            objectMap.put("uid", uids);
            // 通过deptId dutyType uid   来查询三个表的信息  department , user ,user_ext
            //这个地方有问题
            List<Users> usersList = usersMapper.getUsersByMaps(objectMap);
            //List<Attend> attends = attendMapper.queryExportAttend(map);
           // List<Attend> attendList = attendMapper.selectAttend(Map);
            Iterator<Users> usersIterator = usersList.iterator();
            Date dateTime = new Date();
            SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
            String time = format.format(dateTime);
            Date dateTime1 = new Date();
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
            String time1 = format1.format(dateTime1);

            List<AttendStatistics> attendStatisticAll=new ArrayList<>();
            while (usersIterator.hasNext()) {
                List<Date> date = new ArrayList<Date>();
                Users users = usersIterator.next();

                Integer uid=users.getUid();
                //根据用户id   查询用户扩展信息
                String deptName=users.getDeptName();
                UserExt userExt = userExtMapper.queryUserExt(users.getUid());
                if (userExt != null) {
                    List<BaseAttend> normal = new ArrayList<BaseAttend>();//上班正常
                    List<BaseAttend> normalyichang = new ArrayList<BaseAttend>();//设备异常
                    List<BaseAttend> closed = new ArrayList<BaseAttend>();//下班正常
                    List<BaseAttend> notSign = new ArrayList<BaseAttend>();//未签到
                    List<BaseAttend> notOut = new ArrayList<BaseAttend>();//未签退
                    List<BaseAttend> leaveEarly = new ArrayList<BaseAttend>();//早退
                    List<BaseAttend> late = new ArrayList<BaseAttend>();//迟到
                    List<BaseAttend> fields = new ArrayList<BaseAttend>();//外勤
                    List<BaseAttend>  attendance=new ArrayList<BaseAttend>();//加班
                    List<BaseAttend>  evection=new ArrayList<BaseAttend>();//出差
                    List<BaseAttend> leave =new ArrayList<BaseAttend>();//请假
                    List<BaseAttend> out =new ArrayList<BaseAttend>();//外出


                    //根据dutyType  查询考勤设置表所有信息
                    AttendSet attendSet = attendSetMapper.selectAttendSetSid(Integer.valueOf(userExt.getDutyType()));
                    int xqhbt = 0;
                    //第一次签到开关
                    String[] str1 = attendSet.getAtime1Set().split("\\|");
              /*  public final String numberZero = "0";
                public final String numberOne = "1";
                public final String numberTwo = "2";
                public final String numberThree = "3";
                public final String numberFour = "4";*/
                    if (numberOne.equals(str1[0])) {
                        xqhbt++;
                    }
                    //第一次签到开关
                    attendSet.setAtime1Setother(str1[0]);
                    //第一次上下班开关
                    attendSet.setCommute1(str1[1]);
                    String[] str2 = attendSet.getAtime2Set().split("\\|");
                    if (numberOne.equals(str2[0])) {
                        xqhbt++;
                    }
                    attendSet.setAtime2Setother(str2[0]);
                    attendSet.setCommute2(str2[1]);
                    String[] str3 = attendSet.getAtime3Set().split("\\|");
                    if (numberOne.equals(str3[0])) {
                        xqhbt++;
                    }
                    attendSet.setAtime3Setother(str3[0]);
                    attendSet.setCommute3(str3[1]);
                    String[] str4 = attendSet.getAtime4Set().split("\\|");
                    if (numberOne.equals(str4[0])) {
                        xqhbt++;
                    }
                    attendSet.setAtime4Setother(str4[0]);
                    attendSet.setCommute4(str4[1]);
                    String[] str5 = attendSet.getAtime5Set().split("\\|");
                    if (numberOne.equals(str5[0])) {
                        xqhbt++;
                    }
                    attendSet.setAtime5Setother(str5[0]);
                    attendSet.setCommute5(str5[1]);
                    String[] str6 = attendSet.getAtime6Set().split("\\|");
                    if (numberOne.equals(str6[0])) {
                        xqhbt++;
                    }

                    Calendar c = Calendar.getInstance();
                    List<Date> dates = DateCompute.getBetweenDates(DateFormat.DateToStr(beiginDate), DateFormat.DateToStr(endDate));
                    for (Date nowdate1 : dates) {
                        c.setTime(nowdate1);
                        int weekInt = c.get(Calendar.DAY_OF_WEEK);
                        weekInt = weekInt - 1;
                        if (weekInt == 0) {
                            weekInt = 7;
                        }

                        String week = String.valueOf(weekInt);
                        if (attendSet.getWorkdate().contains(week)) {
                            date.add(nowdate1);
                        }
                    }
                    normalyichang   = myAttendUnitException(beiginDate, endDate, uid, req);//手动去添加开始时间和结束时间去查询输入的时间段内的考勤统计
                    for (Date nowdate : date) {
                        if (numberOne.equals(attendSet.getIsOut())) {
                            List<Attend> attend0 = attendMapper.selectAttend0(DateFormat.getDatestr(nowdate), uid);
                            if (attend0 != null && attend0.size() > 0) {
                                Iterator<Attend> attendIterator = attend0.iterator();
                                while (attendIterator.hasNext()) {
                                    Field field = new Field();//外勤
                                    Attend attend1 = attendIterator.next();
                                    field.setDate(DateFormat.getDatestrTime(nowdate));
                                    field.setTime(DateFormat.getwyqStrTime(attend1.getAtime()));
                                    field.setStr(attend1.getAddress());
                                    field.setPhoneId(attend1.getPhoneId());
                                    field.setCause(attend1.getRemark());
                                    fields.add(field);
                                }
                            }

                        }
                        if (numberOne.equals(attendSet.getAtime1Setother())) {
                            String status = "";
                            if (DateFormat.getDateTimes(attendSet.getAtime1()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                                if (numberOne.equals(attendSet.getCommute1())) {
                                    Attend attend1 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberOne);
                                    if (attend1 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend1.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime1()).getTime()) {
                                            status = "迟到";
                                            BaseAttend latesix = new BaseAttend();

                                            latesix.setStr("签到时间为：" + attendSet.getAtime1() + "迟到(" + DateFormat.parseMillisecone(attend1.getAtime() - DateFormat.getWYQTime(attendSet.getAtime1())) + ")");


                                            late.add(latesix);
                                        } else {
                                            status = "正常";
                                            BaseAttend normalB = new BaseAttend();
                                            normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend1.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            normal.add(normalB);
                                        }
                                    }else {
                                        status = "未签到";
                                        BaseAttend notSignsix = new BaseAttend();
                                        notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime1() + ")");
                                        notSign.add(notSignsix);
                                    }

                                } else {
                                    Attend attend1 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberOne);
                                    if (attend1 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend1.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime1()).getTime()) {
                                            status = "早退";
                                            BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                            leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend1.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime1()) - attend1.getAtime()) + ")");

                                            leaveEarly.add(leaveEarlysix);
                                        } else {
                                            status = "正常";
                                            BaseAttend closedB = new BaseAttend();
                                            closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend1.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            closed.add(closedB);

                                        }

                                    } else {
                                        status = "未签到";
                                        BaseAttend notOutsix = new BaseAttend();
                                        notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime1() + ")");
                                        notOut.add(notOutsix);
                                    }


                                }
                            }
                        }
                        if (numberOne.equals(attendSet.getAtime2Setother())) {
                            String status = "";
                            if (DateFormat.getDateTimes(attendSet.getAtime2()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                                if (numberOne.equals(attendSet.getCommute2())) {
                                    Attend attend2 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberTwo);
                                    if (attend2 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend2.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime2()).getTime()) {
                                            status = "迟到";
                                            BaseAttend latesix = new BaseAttend();

                                            latesix.setStr("签到时间为：" + attendSet.getAtime2() + "迟到(" + DateFormat.parseMillisecone(attend2.getAtime() - DateFormat.getWYQTime(attendSet.getAtime2())) + ")");


                                            late.add(latesix);
                                        } else {
                                            status = "正常";
                                            BaseAttend normalB = new BaseAttend();
                                            normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend2.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            normal.add(normalB);
                                        }
                                    } else {
                                        status = "未签到";
                                        BaseAttend notSignsix = new BaseAttend();
                                        notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime2() + ")");
                                        notSign.add(notSignsix);
                                    }

                                } else {
                                    Attend attend2 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberTwo);
                                    if (attend2 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend2.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime2()).getTime()) {
                                            status = "早退";
                                            BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                            leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend2.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime2()) - attend2.getAtime()) + ")");

                                            leaveEarly.add(leaveEarlysix);
                                        } else {
                                            status = "正常";
                                            BaseAttend closedB = new BaseAttend();
                                            closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend2.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            closed.add(closedB);

                                        }

                                    } else {
                                        status = "未签到";
                                        BaseAttend notOutsix = new BaseAttend();
                                        notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime2() + ")");
                                        notOut.add(notOutsix);
                                    }


                                }
                            }
                        }
                        if (numberOne.equals(attendSet.getAtime3Setother())) {
                            String status = "";
                            if (DateFormat.getDateTimes(attendSet.getAtime3()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                                if (numberOne.equals(attendSet.getCommute3())) {
                                    Attend attend3 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberThree);
                                    if (attend3 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend3.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime3()).getTime()) {
                                            status = "迟到";
                                            BaseAttend latesix = new BaseAttend();

                                            latesix.setStr("签到时间为：" + attendSet.getAtime3() + "迟到(" + DateFormat.parseMillisecone(attend3.getAtime() - DateFormat.getWYQTime(attendSet.getAtime3())) + ")");


                                            late.add(latesix);
                                        } else {
                                            status = "正常";
                                            BaseAttend normalB = new BaseAttend();
                                            normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend3.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            normal.add(normalB);
                                        }
                                    } else {
                                        status = "未签到";
                                        BaseAttend notSignsix = new BaseAttend();
                                        notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime3() + ")");
                                        notSign.add(notSignsix);
                                    }

                                } else {
                                    Attend attend3 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberThree);
                                    if (attend3 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend3.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime3()).getTime()) {
                                            status = "早退";
                                            BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                            leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend3.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime3()) - attend3.getAtime()) + ")");

                                            leaveEarly.add(leaveEarlysix);
                                        } else {
                                            status = "正常";
                                            BaseAttend closedB = new BaseAttend();
                                            closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend3.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            closed.add(closedB);

                                        }

                                    } else {
                                        status = "未签到";
                                        BaseAttend notOutsix = new BaseAttend();
                                        notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime3() + ")");
                                        notOut.add(notOutsix);
                                    }


                                }
                            }
                        }
                        if (numberOne.equals(attendSet.getAtime4Setother())) {
                            String status = "";
                            if (DateFormat.getDateTimes(attendSet.getAtime4()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                                if (numberOne.equals(attendSet.getCommute4())) {
                                    Attend attend4 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFour);
                                    if (attend4 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend4.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime4()).getTime()) {
                                            status = "迟到";
                                            BaseAttend latesix = new BaseAttend();

                                            latesix.setStr("签到时间为：" + attendSet.getAtime4() + "迟到(" + DateFormat.parseMillisecone(attend4.getAtime() - DateFormat.getWYQTime(attendSet.getAtime4())) + ")");


                                            late.add(latesix);
                                        } else {
                                            status = "正常";
                                            BaseAttend normalB = new BaseAttend();
                                            normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend4.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            normal.add(normalB);
                                        }
                                    } else {
                                        status = "未签到";
                                        BaseAttend notSignsix = new BaseAttend();
                                        notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime4() + ")");
                                        notSign.add(notSignsix);
                                    }

                                } else {
                                    Attend attend4 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFour);
                                    if (attend4 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend4.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime4()).getTime()) {
                                            status = "早退";
                                            BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                            leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend4.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime4()) - attend4.getAtime()) + ")");

                                            leaveEarly.add(leaveEarlysix);
                                        } else {
                                            status = "正常";
                                            BaseAttend closedB = new BaseAttend();
                                            closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend4.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            closed.add(closedB);

                                        }

                                    } else {
                                        status = "未签到";
                                        BaseAttend notOutsix = new BaseAttend();
                                        notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime4() + ")");
                                        notOut.add(notOutsix);
                                    }


                                }
                            }
                        }
                        if (numberOne.equals(attendSet.getAtime5Setother())) {
                            String status = "";
                            if (DateFormat.getDateTimes(attendSet.getAtime5()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                                if (numberOne.equals(attendSet.getCommute5())) {
                                    Attend attend5 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFive);
                                    if (attend5 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend5.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime5()).getTime()) {
                                            status = "迟到";
                                            BaseAttend latesix = new BaseAttend();

                                            latesix.setStr("签到时间为：" + attendSet.getAtime5() + "迟到(" + DateFormat.parseMillisecone(attend5.getAtime() - DateFormat.getWYQTime(attendSet.getAtime5())) + ")");
                                            latesix.setSignStatus(status);
                                            latesix.setSignTimeStr("规定签到时间为：" + attendSet.getAtime5() + "签到时间：(" + DateFormat.parseMillisecone(attend5.getAtime()) + ")");

                                            late.add(latesix);
                                        } else {
                                            status = "正常";
                                            BaseAttend normalB = new BaseAttend();
                                            normalB.setSignStatus(status);
                                            //  normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend5.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            normalB.setSignTimeStr("规定签到时间为：" + attendSet.getAtime5() + "签到时间：(" + DateFormat.parseMillisecone(attend5.getAtime()) + ")");

                                            normal.add(normalB);
                                        }
                                    } else {
                                        status = "未签到";
                                        BaseAttend notSignsix = new BaseAttend();
                                        notSignsix.setSignStatus(status);
                                        notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime5() + ")");
                                        notSign.add(notSignsix);
                                    }

                                } else {
                                    Attend attend5 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberFive);
                                    if (attend5 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend5.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime5()).getTime()) {
                                            status = "早退";
                                            BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                            leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend5.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime5()) - attend5.getAtime()) + ")");

                                            leaveEarly.add(leaveEarlysix);
                                        } else {
                                            status = "正常";
                                            BaseAttend closedB = new BaseAttend();
                                            closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend5.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            closed.add(closedB);

                                        }

                                    } else {
                                        status = "未签到";
                                        BaseAttend notOutsix = new BaseAttend();
                                        notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime5() + ")");
                                        notOut.add(notOutsix);
                                    }


                                }
                            }
                        }
                        if (numberOne.equals(attendSet.getAtime6Setother())) {
                            String status = "";
                            if (DateFormat.getDateTimes(attendSet.getAtime6()).getTime() < DateFormat.getDateTimes(time).getTime() || !date.equals(time1)) {

                                if (numberOne.equals(attendSet.getCommute6())) {
                                    Attend attend6 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberSix);
                                    if (attend6 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend6.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() > DateFormat.getDateTimes(attendSet.getAtime6()).getTime()) {
                                            status = "迟到";
                                            BaseAttend latesix = new BaseAttend();

                                            latesix.setStr("签到时间为：" + attendSet.getAtime6() + "迟到(" + DateFormat.parseMillisecone(attend6.getAtime() - DateFormat.getWYQTime(attendSet.getAtime6())) + ")");


                                            late.add(latesix);
                                        } else {
                                            status = "正常";
                                            BaseAttend normalB = new BaseAttend();
                                            normalB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend6.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            normal.add(normalB);
                                        }
                                    }else {
                                        status = "未签到";
                                        BaseAttend notSignsix = new BaseAttend();
                                        notSignsix.setStr("未签到(规定签到时间为：" + attendSet.getAtime6() + ")");
                                        notSign.add(notSignsix);
                                    }

                                } else {
                                    Attend attend6 = attendMapper.selectAttendAll(DateFormat.getDatestr(nowdate), uid, numberSix);
                                    if (attend6 != null) {

                                        String a1 = DateFormat.getwyqStrTime(attend6.getAtime());
                                        if (DateFormat.getDateTimes(a1).getTime() < DateFormat.getDateTimes(attendSet.getAtime6()).getTime()) {
                                            status = "早退";
                                            BaseAttend leaveEarlysix = new BaseAttend();

//                                        long timeDate=DateFormat.getDateTimes(a1).getTime() - DateFormat.getDateTimes(attendSet.getAtime1()).getTime();
//                                        int i1 = (int)timeDate;
//                                        Integer i2=i1;
                                            leaveEarlysix.setStr("签到时间为：" + DateFormat.getwyqStrTime(attend6.getAtime()) + "早退(" + DateFormat.parseMillisecone(DateFormat.getWYQTime(attendSet.getAtime6()) - attend6.getAtime()) + ")");

                                            leaveEarly.add(leaveEarlysix);
                                        } else {
                                            status = "正常";
                                            BaseAttend closedB = new BaseAttend();
                                            closedB.setStr("签到时间：" + DateFormat.getwyqStrTime(attend6.getAtime())/*+"迟到"+DateFormat.getwyqStrTime(i2)*/);
                                            closed.add(closedB);

                                        }

                                    } else {
                                        status = "weiqiandao";
                                        BaseAttend notOutsix = new BaseAttend();
                                        notOutsix.setStr("未签退(规定签到时间为：" + attendSet.getAtime6() + ")");
                                        notOut.add(notOutsix);
                                    }


                                }
                            }
                        }
                    }
              /*  List<BaseAttend> normal = new ArrayList<BaseAttend>();//上班正常
                List<BaseAttend> normalyichang = new ArrayList<BaseAttend>();//设备异常
                List<BaseAttend> closed = new ArrayList<BaseAttend>();//下班正常
                List<BaseAttend> notSign = new ArrayList<BaseAttend>();//未签到
                List<BaseAttend> notOut = new ArrayList<BaseAttend>();//未签退
                List<BaseAttend> leaveEarly = new ArrayList<BaseAttend>();//早退
                List<BaseAttend> late = new ArrayList<BaseAttend>();//迟到
                List<BaseAttend> fields = new ArrayList<BaseAttend>();//外勤*/
              /*
              *      List<BaseAttend> normal = new ArrayList<BaseAttend>();//上班正常
                List<BaseAttend> normalyichang = new ArrayList<BaseAttend>();//设备异常
                List<BaseAttend> closed = new ArrayList<BaseAttend>();//下班正常
                List<BaseAttend> notSign = new ArrayList<BaseAttend>();//未签到
                List<BaseAttend> notOut = new ArrayList<BaseAttend>();//未签退
                List<BaseAttend> leaveEarly = new ArrayList<BaseAttend>();//早退
                List<BaseAttend> late = new ArrayList<BaseAttend>();//迟到
                List<BaseAttend> fields = new ArrayList<BaseAttend>();//外勤
                List<BaseAttend>  attendance=new ArrayList<BaseAttend>();//加班
                List<BaseAttend>  evection=new ArrayList<BaseAttend>();//出差
                List<BaseWrapper> qingjia =new ArrayList<BaseWrapper>();//请假
                List<BaseWrapper> out =new ArrayList<BaseWrapper>();//外出

              * */

                    AttendStatistics attendStatistics=new AttendStatistics();
                    attendStatistics.setUserName(users.getUserName());
                    System.out.println("aaa"+users.getDeptName());
                    attendStatistics.setDeptName(users.getDeptName());
                    System.out.println("uid"+users.getUid());
                    attendStatistics.setUid(users.getUid());

                    attendStatistics.setCount1(normal.size());
                    attendStatistics.setCount1List(normal);//上班正常

                    attendStatistics.setCount2(closed.size());
                    attendStatistics.setCount2List(closed);//下班正常

                    attendStatistics.setCount3(notSign.size());
                    attendStatistics.setCount3List(notSign);//未签到

                    attendStatistics.setCount4(notOut.size());
                    attendStatistics.setCount4List(notOut);//未签退

                    attendStatistics.setCount5(late.size());
                    attendStatistics.setCount5List(late);//迟到

                    attendStatistics.setCount6(leaveEarly.size());
                    attendStatistics.setCount6List(leaveEarly);//早退

                    attendStatistics.setCount7(normalyichang.size());
                    attendStatistics.setCount7List(normalyichang);//異常

                    attendStatistics.setCount8(fields.size());
                    attendStatistics.setCount8List(fields);//外勤

                    attendStatistics.setCount9(attendance.size());
                    attendStatistics.setCount9List(attendance);//加班

                    attendStatistics.setCount10(evection.size());
                    attendStatistics.setCount10List(evection);//出差

                    attendStatistics.setCount11(leave.size());
                    attendStatistics.setCount11List(leave);//请假

                    attendStatistics.setCount12(out.size());
                    attendStatistics.setCount12List(out);//外出

                    attendStatisticAll.add(attendStatistics);

                }
            }
            if(attendStatisticAll.size()>0){
                wrappers.setFlag(true);
                wrappers.setStatus(true);
                wrappers.setData(attendStatisticAll);
                wrappers.setMsg("查询成功");
            }else {
                wrappers.setFlag(false);
                wrappers.setStatus(true);
                wrappers.setMsg("查询失败");
            }
            return wrappers;
        }

        //考勤在位时间个人查询（从上班签到到下班签到）算出这段时间总和。显示在页面。
        public ToJson  selectAttendDateExamine (Attend attend) {
            ToJson toJson = new ToJson();
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("date",attend.getDate());
            map.put("uid",attend.getUid());
            List<Attend> dateList = attendMapper.selectAttendDateExamine(map);
            HashMap<String, Object> maps = new HashMap<>();
            List<String> dateStrList =new ArrayList<String>();
            List<Integer> time1=new ArrayList();
            List<Integer> time2=new ArrayList();
                    //遍历取出值两两计算求和
                    for (Attend alist : dateList){
                        String key = alist.getType();//key
                        int value = alist.getAtime();//value。
                        maps.put(key,value);
                    }
                    int atime1 = 0;
                    int atime2 = 0;
                    if(maps.size()%2==0){
                        if (maps.size()==2){
                            int Time = 0;
                            for (Map.Entry<String, Object> entry : maps.entrySet()) {
                                if ((Integer.parseInt(entry.getKey()))%2!=0){
                                    time1.add((Integer) entry.getValue());
                                }else {
                                    time2.add((Integer) entry.getValue());
                                }
                            }
                            int sum = 0;
                            for (int i=0;i<time1.size();i++){
                                int a = time2.get(i)-time1.get(i);
                                sum+=a;
                                String atime = DateFormat.getwyqStrTime(sum);
                                toJson.setMsg("两次签到，请查阅签到详情");
                                toJson.setFlag(0);
                                toJson.setObject(atime);
                            }
                        }else {
                            if (maps.size()>=4 && maps.size()%2==0 ){
                                int Time = 0;
                                for (Map.Entry<String, Object> entry : maps.entrySet()) {
                                    if ((Integer.parseInt(entry.getKey()))%2!=0){
                                        time1.add((Integer) entry.getValue());
                                    }else {
                                        time2.add((Integer) entry.getValue());
                                    }
                                }
                                int sum = 0;
                                for (int i=0;i<time1.size();i++){
                                    int a = time2.get(i)-time1.get(i);
                                    sum+=a;
                                    String atime = DateFormat.getwyqStrTime(sum);
                                    toJson.setFlag(0);
                                    toJson.setMsg("ok");
                                    toJson.setObject(atime);
                                }
                            }
                }
            }else {
                toJson.setFlag(1);
                toJson.setMsg("签到数为单数。无法计算个人在位时长");
            }
            //如果为单数就不成对 不可以作为数据。 签到能打多少次不知道。不能写在map中
            return toJson;
            }





        //以下为有问题的代码下面我给出了那有问题
        //考勤在位时间全体查询（从上班签到到下班签到）算出这段时间总和。显示在页面。
        public ToJson  AllselectAttendDateExamine (Attend attend) {
            ToJson toJson = new ToJson();
            List<Object> sumAtime = new ArrayList<>();//计算出的结果的集合
            List<Object> attenda = new ArrayList<>(); //计算的对象的集合（和计算出的结果是一一对应的）
            try {
            List<Attend> attends = attendMapper.AllselectAttendDateExamine(attend);
                HashMap<String, Object> maps = new HashMap<>();
                List<List<Attend>> dateStrList =new ArrayList<>();
                List<List<Attend>> dateStrList1= new ArrayList<>();
                List<Integer> time1=new ArrayList();
                List<Integer> time2=new ArrayList();
                List<Attend> attlist = new ArrayList<>();
                List<Attend> attlist1 = new ArrayList<>();
                HashMap<Date, Object> map1 = new HashMap<>();
                //这是查出的所有值按uid分好类放入这个map
                Map<Integer, List<Attend>> map = new HashMap<Integer, List<Attend>>();
                for(Attend attend1:attends){
                    if(map.get(attend1.getUid())==null){
                        List<Attend>  list = new ArrayList<Attend>();
                        list.add(attend1);
                        map.put(attend1.getUid(), list);
                    }else{
                        List<Attend> list = map.get(attend1.getUid());
                       list.add(attend1);}
                }
                //map中key为id  value为list集合
                 for (Map.Entry<Integer,List<Attend>> entry : map.entrySet()){
                    dateStrList1.add(entry.getValue());
                    //分类分好了  现在dateStrList中是key为空的。  dateStrList中是Key有值的  key值为用户uid
                    //value中存在的是list集合  是为同一个uid中的不同日期的不同签到记录。
                }


                //  Map<Integer, Map<Date, Attend>> attends = new HashMap<Integer, Map<Date, Attend>>();





                //dateStrList1 7个list 这个7个list中每一个list中都是uid相同的对象
                for (List<Attend> attendList : dateStrList1) {
                //这里的没有逻辑  就是forforforfor。。。。。我已经绕晕于此
                    for (int i = 0; i < attendList.size(); i++) {
//                        Date date1 = (attendList.get(i)).getDate();
//                        if ((attendList.get(i)).getDate() == date1) {
//                            attlist.add(attendList.get(i));
//                        }else {
//                            attlist1.add(attendList.get(i));
//                        }
                    }
//                    for (Attend alist : attendList){
                    //这里为循环计算  只要拿出相同日期的签到数放入map中就可以计算。 返回值问题没解决。怎么返回没解决
                    for (Attend attend1 : attlist) {
                        String key = attend1.getType();//key
                        int value = attend1.getAtime();//value。
                        maps.put(key, value);
                        int atime1 = 0;
                        int atime2 = 0;
                        if (maps.size() % 2 == 0) {
                            if (maps.size() == 2) {
                                int Time = 0;
                                for (Map.Entry<String, Object> entry1 : maps.entrySet()) {
                                    if ((Integer.parseInt(entry1.getKey())) % 2 != 0) {
                                        time1.add((Integer) entry1.getValue());
                                    } else {
                                        time2.add((Integer) entry1.getValue());
                                    }
                                }
                                int sum = 0;
                                for (int i = 0; i < time1.size(); i++) {
                                    int a = time2.get(i) - time1.get(i);
                                    sum += a;
                                    String atime = DateFormat.getwyqStrTime(sum);
                                    // toJson.setMsg("两次签到，请查阅签到详情");
                                    sumAtime.add(atime);

                                }
                            } else {
                                if (maps.size() >= 4 && maps.size() % 2 == 0) {
                                    int Time = 0;
                                    for (Map.Entry<String, Object> entry1 : maps.entrySet()) {
                                        if ((Integer.parseInt(entry1.getKey())) % 2 != 0) {
                                            time1.add((Integer) entry1.getValue());
                                        } else {
                                            time2.add((Integer) entry1.getValue());
                                        }
                                    }
                                    int sum = 0;
                                    for (int i = 0; i < time1.size(); i++) {
                                        int a = time2.get(i) - time1.get(i);
                                        sum += a;
                                        String atime = DateFormat.getwyqStrTime(sum);
//                                        toJson.setFlag(0);
//                                        toJson.setMsg("ok");
                                        sumAtime.add(atime);
                                    }
                                }
                            }
                        } else {
//                            toJson.setFlag(1);
//                            toJson.setMsg("签到数为单数。无法计算个人在位时长");
                            sumAtime.add("签到数为单数。无法计算个人在位时长");
                        }
                    }
                    // }
                }

        } catch (Exception e) {
            e.printStackTrace();
        }
            toJson.setObject(attenda);
            toJson.setObj(sumAtime);
            return toJson;
        }

        /**
         * 根据UID查询 考勤的时间
         * @param uid
         * @return
         */
        // usersMapper.getUsersByMaps();
        public ToJson selectAttendDate(Integer uid){

            ToJson toJson=new ToJson();
            List<Date> dateList=attendMapper.selectAttendDate(uid);
            List<Map<String,Object>> list=new ArrayList<>();

            for(Date date:dateList){
                Map<String,Object> map=new LinkedHashMap<String,Object>();
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String date2=simpleDateFormat.format(date);
                map.put("date2",date2);

                SimpleDateFormat simpleDateFormat1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String date3=simpleDateFormat1.format(new Date());

                list.add(map);
            }
            if(list!=null){

                toJson.setFlag(0);
                toJson.setMsg("查询成功");
                toJson.setObj(list);
            }else{
                toJson.setFlag(0);
                toJson.setMsg("日期为空");
            }

            return toJson;
        }

        /**
         * 导出
         * @param request
         * @param response
         * @param user
         * @param sortType
         * @param isExport
         * @param notLogin
         * @return
         */


        public ToJson<Attend> queryExportAttend(HttpServletRequest request,HttpServletResponse response, Attend attend) {
            ToJson<Attend> json = new ToJson<Attend>();

            try {
               Map<String, Object> map = new HashMap<String, Object>();
     //         map.put("uid", attend.getUid());
                List<Attend> attends = attendMapper.queryExportAttend(map);
                if (attends != null) {
                    json.setObj(attends);
                    json.setFlag(0);
                    json.setMsg("ok");
                } else {
                    json.setFlag(1);
                    json.setMsg("err");
                }
                    HSSFWorkbook workbook1 = ExcelUtil.makeExcelHead("考勤信息", 9);
                    String[] secondTitles = {"id","姓名", "部门", "角色", "登记时间", "签到时间","角色编号","角色排序号"};
                    HSSFWorkbook workbook2 = ExcelUtil.makeSecondHead(workbook1, secondTitles);
                    String[] beanProperty = {"uid","userName", "depName","userPrivName","date", "atime", "userPriv","userPrivNo"};

                    HSSFWorkbook workbook = ExcelUtil.exportExcelData(workbook2, attends, beanProperty);
                    ServletOutputStream out = response.getOutputStream();

                    String filename = "考勤信息表.xls";
                    filename = FileUtils.encodeDownloadFilename(filename, request.getHeader("user-agent"));
                    response.setContentType("application/vnd.ms-excel");
                    response.setHeader("content-disposition", "attachment;filename=" + filename);
                    workbook.write(out);
                    out.close();

            } catch (Exception e) {
                e.printStackTrace();
                json.setMsg("err");
                json.setFlag(1);
            }
            return json;
        }

    }


